﻿Imports MySql.Data.MySqlClient
Public Class frmrpt_gateout
    Dim mysql As MySqlConnection = main_form.mysqlconection
    Dim mySqlCommand As New MySqlCommand
    Dim mySqlAdaptor As New MySqlDataAdapter
    Dim mySqlReader As MySqlDataReader
    Dim rpt1 As New rptgate_out2

    Private Sub frmrpt_gateout_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CrystalReportViewer1.ReportSource = rpt1


        CrystalReportViewer1.Refresh()
        System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
        System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture
        mysql.Close()
        If mysql.State = ConnectionState.Closed Then
            mysql.Open()
        End If
        mySqlCommand.CommandText = "Select * from borrow join booking on borrow.BOOKID = booking.BOOKINGID join voyage on voyage.VOYAGEID = booking.BVOYAGE  join shipper on shipper.SHIPPERID = booking.BSHIP join ctnmain on ctnmain.CTNMAINID = borrow.CTNID   where idborrow ='" & frmview_voyage.idborrow & "' ;"
        ' mySqlCommand.CommandText = 
        mySqlCommand.Connection = mysql
        mySqlAdaptor.SelectCommand = mySqlCommand

        Try
            mySqlReader = mySqlCommand.ExecuteReader

            While (mySqlReader.Read())
                If mySqlReader("REMARK") Is DBNull.Value Then
                    rpt1.SetParameterValue("remark", "-")
                Else
                    rpt1.SetParameterValue("remark", mySqlReader("REMARK"))
                End If
                rpt1.SetParameterValue("commudity", mySqlReader("BCOM"))

                rpt1.SetParameterValue("dateday", mySqlReader("TIMEDATE"))
                rpt1.SetParameterValue("datetime", mySqlReader("TIMEHHMM"))
                rpt1.SetParameterValue("bookno", mySqlReader("BNO"))
                rpt1.SetParameterValue("ctnno", mySqlReader("CTNSTRING"))
                If mySqlReader("CTNSEALID") Is DBNull.Value Then
                    rpt1.SetParameterValue("ctnseal", "-")
                Else
                    rpt1.SetParameterValue("ctnseal", mySqlReader("CTNSEALID"))
                End If
                rpt1.SetParameterValue("agent", mySqlReader("CTNAGENT"))
                rpt1.SetParameterValue("ctnsize", mySqlReader("CTNSIZE"))
                rpt1.SetParameterValue("shipper", mySqlReader("SHIPNICKNAME"))
                rpt1.SetParameterValue("consignee", mySqlReader("BNFORWARDERNAME"))

                rpt1.SetParameterValue("transport", mySqlReader("COMNAME"))
                rpt1.SetParameterValue("carid", mySqlReader("CARID"))
                rpt1.SetParameterValue("vesselname", mySqlReader("VOYVESNAMES"))
                rpt1.SetParameterValue("voyage", Format(mySqlReader("VOYAGEID"), "000"))
                If mySqlReader("POL") Is DBNull.Value Then
                    rpt1.SetParameterValue("portload", "-")
                Else
                    rpt1.SetParameterValue("portload", mySqlReader("POL"))
                End If
                If mySqlReader("TSPORT") Is DBNull.Value Then
                    rpt1.SetParameterValue("tsport", "-")
                Else
                    rpt1.SetParameterValue("tsport", mySqlReader("TSPORT"))
                End If
                If mySqlReader("BFINALDEST") Is DBNull.Value Then
                    rpt1.SetParameterValue("pofd", "")
                Else
                    rpt1.SetParameterValue("pofd", mySqlReader("BFINALDEST"))
                End If
                rpt1.SetParameterValue("ctnlocation", "")

            End While
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        mysql.Close()


    End Sub

    Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load

    End Sub
End Class